package com.cloud_notes.demo.common.pojo.response;


import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;

//返回前端需要的内容
@Data
public class BlogInfoResponse {
    private Integer id;
    private String title;
    private String content;
    private Integer userId;
    private String blogType;
    private String imageUrl;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    public void setTruncatedContent(String originalContent) {
        this.content = originalContent != null ?
                (originalContent.length() > 50 ?
                        originalContent.substring(0, 50)+"......" :
                        originalContent) :
                "";
    }
}
